import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "layout",
    redirect: "/home",
    component: () =>
      import(/* webpackChunkName: "about" */ "@/views/layout/index.vue"),
    children: [
      {
        path: "/home",
        name: "home",
        component: () =>
          import(/* webpackChunkName: "about" */ "@/views/home/index.vue"),
      },
      {
        path: "/select/car",
        name: "selectCar",
        component: () =>
          import(/* webpackChunkName: "about" */ "@/views/selectCar/index.vue"),
      },
    ],
  },
  {
    path: "/car/:name/:id",
    name: "car",
    component: () =>
      import(/* webpackChunkName: "about" */ "@/views/carDetail/index.vue"),
    // 开启路由传参模式  将路由的动态参数  通过 props 传递给组件
    props: true,
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
